import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  // 这部分是什么作用？注释掉也不影响首页跳转
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  // lty-试写用户注册
  {
    path: '/register',
    component: () => import('@/views/register/index'),
    hidden: false
  },
  // lty-试写服务商注册
  {
    path: '/registerServiceProvider',
    component: () => import('@/views/registerServiceProvider/index'),
    hidden: false
  },
  // {
  //   path: '/re',
  //   component: Layout,
  //   redirect: '/re/register',
  //   // 这里开始对应的路由都会显示在app-main中 如上图所示
  //   children: [{
  //     path: 'register',
  //     name: 'Register',//路由的名字
  //     component: () => import('@/views/Homepage/lawOffice/index'),
  //     meta: { title: '注册', icon: 'dashboard' }
  //   }]
  // },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  // 首页
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    // hidden:false,
    // 这里开始对应的路由都会显示在app-main中 如上图所示
    children: [{
      path: 'dashboard',
      name: 'Dashboard',//路由的名字
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },
  // 公司服务
  {
    path: '/compServer',
    component: Layout,
    redirect: '/compServer/setup',
    name: 'compServer',
    meta: { title: '公司服务', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'setup',
        name: 'setup',
        component: () => import('@/views/Homepage/compServer/setup/index'),
        meta: { title: '公司设立', icon: 'table' }
      },
      // {
      //   path: 'setupInput',
      //   name: 'setupInput',
      //   component: () => import('@/views/Homepage/compServer/setupInput/index'),
      //   meta: { title: '公司设立信息填写', icon: 'table' }
      // },
      {

        path: 'change',
        name: 'change',
        component: () => import('@/views/Homepage/compServer/change/index'),
        meta: { title: '公司变更', icon: 'tree' }
      },
      {
        path: 'report',
        name: 'report',
        component: () => import('@/views/Homepage/compServer/report/index'),
        meta: { title: '工商年报', icon: 'tree' }
      },
      {
        path: 'infoShow',
        name: 'infoShow',
        component: () => import('@/views/Homepage/compServer/infoShow/index'),
        meta: { title: '信息公示', icon: 'tree' }
      },
      // {
      //   path: 'compLogout',
      //   name: 'compLogout',
      //   component: () => import('@/views/Homepage/compServer/compLogout/index'),
      //   meta: { title: '企业注销', icon: 'tree' }
      // },
    ]
  },
  // 知识产权
  {
    path: '/IP',
    component: Layout,
    redirect: '/IP/IPlist',
    name: 'IP',
    meta: { title: '知识产权', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'IPlist',
        name: 'IPlist',
        component: () => import('@/views/Homepage/IP/IPlist/index'),
        meta: { title: '知识产权', icon: 'tree' }
      },
      {
        path: 'readMore',
        name: 'readMore',
        component: () => import('@/views/Homepage/IP/readMore/index'),
        meta: { title: '知识产权详情', icon: 'tree' },
        hidden:true,
      },
   
    ]
  },
  // 法律文书
  {
    path: '/legalDoc',
    component: Layout,
    redirect: '/legalDoc/custom',
    name: 'legalDoc',
    meta: { title: '法律文书', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'custom',
        name: 'custom',
        component: () => import('@/views/Homepage/legalDoc/custom/index'),
        meta: { title: '合同定制', icon: 'tree' }
      },
    ]
  },
  // 资质证照
  {
    path: '/license',
    component: Layout,
    redirect: '/license/licenseList',
    name: 'license',
    meta: { title: '资质证照', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'licenseList',
        component: () => import('@/views/Homepage/license/licenseList/index'), // Parent router-view
        name: 'licenseList',
        meta: { title: '资质证照', icon: 'el-icon-s-help' }
      },
      {
        path: 'readMore',
        component: () => import('@/views/Homepage/license/readMore/index'), // Parent router-view
        name: 'readMore',
        meta: { title: '资质证照详情', icon: 'el-icon-s-help' },
        hidden:true,
      },
    ]
  },
  // 法律机构
  {
    path: '/lawOffice',
    component: Layout,
    redirect: '/lawOffice',
    name: 'lawOffice',
    meta: { title: '优质机构', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'officeList',
        component: () => import('@/views/Homepage/lawOffice/officeList/index'),
        name: 'readMore',
        meta: { title: '优质机构', icon: 'el-icon-s-help' },
      },
      {
        path: 'readMore',
        component: () => import('@/views/Homepage/lawOffice/readMore/index'),
        name: 'readMore',
        meta: { title: '法律机构详情', icon: 'el-icon-s-help' },
        hidden:true,
      },
    ]
  },
  // 成功案例
  {
    path: '/successCase',
    component: Layout,
    redirect: '/successCase',
    name: 'successCase',
    meta: { title: '成功案例', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'articleList',
        component: () => import('@/views/Homepage/successCase/articleList/index'),
        name: 'articleList',
        meta: { title: '成功案例', icon: 'el-icon-s-help' },
      },
      {
        path: 'readMore',
        component: () => import('@/views/Homepage/successCase/readMore/index'),
        name: 'readMore',
        meta: { title: '成功案例详情', icon: 'el-icon-s-help' },
        hidden:true,
      },
    ]
  },
  

  


]

// 动态路由
export const asyncRoutes = [

  // 【法律求助】

  // 用户法律求助
  {
    path: '/lawHelp',
    component: Layout,
    redirect: '/lawHelp/customerHelpList',
    name: 'customerHelp',
    meta: { title: '用户法律求助', icon: 'el-icon-s-help', roles: ["buyer"] },
    children: [
      {
        path: 'customerHelpList',
        name: 'customerHelpList',
        component: () => import('@/views/Homepage/lawHelp/customerHelpList/index'),
        meta: { title: '我的求助', icon: 'table' }
      },
      {
        path: 'customerAsk',
        name: 'customerAsk',
        component: () => import('@/views/Homepage/lawHelp/customerAsk/index'),
        meta: { title: '发起求助', icon: 'table' },
      },
      {
        path: 'customerReadMore',
        name: 'customerReadMore',
        component: () => import('@/views/Homepage/lawHelp/customerReadMore/index'),
        meta: { title: '查看求助详情', icon: 'tree' },

        hidden:true,
      },
      {
        path: 'customerEditHelp',
        name: 'customerEditHelp',
        component: () => import('@/views/Homepage/lawHelp/customerEditHelp/index'),
        meta: { title: '修改求助信息', icon: 'tree' },
        
        hidden:true,
      },
      {
        path: 'customerChooseLawyerList',
        name: 'customerChooseLawyerList',
        component: () => import('@/views/Homepage/lawHelp/customerChooseLawyerList/index'),
        meta: { title: '查看抢单列表', icon: 'table' },
        
        hidden:true,
      },
    ]
  },

  // 服务商法律援助
  {
    path: '/lawHelp',
    component: Layout,
    redirect: '/lawHelp/helpList',
    name: 'lawHelp',
    meta: { title: '服务商法律援助', icon: 'el-icon-s-help' , roles: ["serviceProvider"] },
    children: [
      {
        path: 'lawyerHelpList',
        name: 'lawyerHelpList',
        component: () => import('@/views/Homepage/lawHelp/lawyerHelpList/index'),
        meta: { title: '法律援助', icon: 'table' }
      },
      {
        path: 'lawyerSelfRecommend',
        name: 'lawyerSelfRecommend',
        component: () => import('@/views/Homepage/lawHelp/lawyerSelfRecommend/index'),
        meta: { title: '抢单自荐', icon: 'tree' },
        
        hidden:true,

        hidden: true,
      },
      {
        path: 'lawyerReadMore',
        name: 'lawyerReadMore',
        component: () => import('@/views/Homepage/lawHelp/lawyerReadMore/index'),
        meta: { title: '服务商查看求助详情', icon: 'tree' },
        
        hidden: true,
      },    
    ]
  },

  // 以下为【用户中心】的侧边栏

  // 【用户中心】
  {
    path: '/customerCenter',
    component: Layout,
    redirect: '/customerCenter/customerAccount',
    name: 'customerCenter',
    // meta: { title: '用户中心', icon: 'el-icon-s-help', roles: ["editor"] },
    meta: { title: '用户中心', icon: 'el-icon-s-help', roles: ["buyer"] },
    children: [
      // 我的账户
      {
        path: 'customerAccount',
        name: 'customerAccount',
        component: () => import('@/views/customerCenter/customerAccount/index'),
        meta: { title: '我的账户', icon: 'table' },
        children: [
          {
            path: 'displayPersonalInfo',
            name: 'displayPersonalInfo',
            component: () => import('@/views/customerCenter/customerAccount/displayPersonalInfo'),
            meta: { title: '查看账户信息', icon: 'table' }
          },
          {
            path: 'editPersonalInfo',
            name: 'editPersonalInfo',
            component: () => import('@/views/customerCenter/customerAccount/editPersonalInfo/index'),
            meta: { title: '编辑账户信息', icon: 'tree' }
          },
          // {
          //   path: 'editTelephone',
          //   name: 'editTelephone',
          //   component: () => import('@/views/customerCenter/customerAccount/editTelephone/index'),
          //   meta: { title: '修改绑定手机号', icon: 'table' }
          // },
          {
            path: 'editPassword',
            name: 'editPassword',
            component: () => import('@/views/customerCenter/customerAccount/editPassword/index'),
            meta: { title: '修改密码', icon: 'table' }
          },
        ]
      },
      // 我的订单
      {
        path: 'customerOrder',
        name: 'customerCenter',
        component: () => import('@/views/customerCenter/customerOrder/index'),
        meta: { title: '我的订单', icon: 'el-icon-s-help', roles: ["buyer"] },
        // meta: { title: '我的订单', icon: 'el-icon-s-help', roles: ["editor"] },
        children: [
          {
            path: 'orderList',
            name: 'orderList',
            component: () => import('@/views/customerCenter/customerOrder/orderList/index'),
            meta: { title: '订单管理', icon: 'table' }
          },
          {
            hidden:true,
            path: 'readMore',
            name: 'readMore',
            component: () => import('@/views/customerCenter/customerOrder/readMore/index'),
            meta: { title: '订单详情', icon: 'tree' }
          },
          {
            hidden:true,
            path: 'pay',
            name: 'pay',
            component: () => import('@/views/customerCenter/customerOrder/pay/index'),
            meta: { title: '订单支付', icon: 'table' }
          },
          {
            hidden:true,
            path: 'assess',
            name: 'assess',
            component: () => import('@/views/customerCenter/customerOrder/assess/index'),
            meta: { title: '订单评价', icon: 'tree' }
          },
          {
            hidden:true,
            path: 'cansel',
            name: 'cansel',
            component: () => import('@/views/customerCenter/customerOrder/cansel/index'),
            meta: { title: '取消订单', icon: 'tree' }
          },
        ]
      },
      // 【用户中心-我的通知】
      {
        path: '/customerNotice',
        name: 'customerNotice',
        component: () => import('@/views/customerCenter/customerNotice/index'),
        meta: { title: '我的通知', icon: 'el-icon-s-help', roles: ['buyer'] },
        // meta: { title: '我的通知', icon: 'el-icon-s-help', roles: ['editor'] },
        children: [
          {
            path: 'displayList',
            name: 'displayList',
            component: () => import('@/views/customerCenter/customerNotice/displayList/index'),
            meta: { title: '我的通知', icon: 'table' }
          },
        ]
      },
    ]
  },

  // admin
  // 【服务商中心】
  {
    path: '/lawyerCenter',
    component: Layout,
    redirect: '/lawyerCenter/lawyerAccount',
    name: 'lawyerCenter',
    meta: { title: '服务商中心', icon: 'el-icon-s-help', roles: ["serviceProvider"] },
    // meta: { title: '服务商中心', icon: 'el-icon-s-help', roles: ["admin"] },
    children: [
      // 【服务商中心-我的账户】
      {
        path: '/lawyerAccount',
        name: 'lawyerAccount',
        component: () => import('@/views/lawyerCenter/lawyerAccount/index'),
        meta: { title: '我的账户', icon: 'el-icon-s-help', roles: ["serviceProvider"] },
        // meta: { title: '我的账户', icon: 'el-icon-s-help', roles: ["admin"] },
        children: [
          {
            path: 'displayPersonalInfo',
            name: 'displayPersonalInfo',
            component: () => import('@/views/lawyerCenter/lawyerAccount/displayPersonalInfo/index'),
            meta: { title: '查看账户信息', icon: 'table' }
          },
          {
            path: 'editPersonalInfo',
            name: 'editPersonalInfo',
            component: () => import('@/views/lawyerCenter/lawyerAccount/editPersonalInfo/index'),
            meta: { title: '编辑账户信息', icon: 'tree' }
          },
          {
            path: 'editPassword',
            name: 'editPassword',
            component: () => import('@/views/lawyerCenter/lawyerAccount/editPassword/index'),
            meta: { title: '修改密码', icon: 'table' }
          },
        ]
      },
      // 【服务商中心-我的订单】
      {
        path: '/lawyerOrder',
        name: 'lawyerOrder',
        component: () => import('@/views/lawyerCenter/lawyerOrder/index'),
        meta: { title: '我的订单', icon: 'test', roles: ['serviceProvider'] },
        children: [
          {
            path: 'orderList',
            name: 'orderList',
            component: () => import('@/views/lawyerCenter/lawyerOrder/orderList/index'),
            meta: { title: '我的订单', icon: 'table' }
          },
          {
            path: 'readMore',
            name: 'readMore',
            component: () => import('@/views/lawyerCenter/lawyerOrder/readMore/index'),
            meta: { title: '订单详情', icon: 'tree' },

            hidden:true
          },
        ]
      },
      // 【服务商中心-我的认证】
      {
        path: '/lawyerCert',
        name: 'lawyerCert',
        component: () => import('@/views/lawyerCenter/lawyerCert/index'),
        meta: { title: '我的认证', icon: 'el-icon-s-help', roles: ['serviceProvider'] },
        // meta: { title: '我的认证', icon: 'el-icon-s-help', roles: ['admin'] },
        children: [
          // {
          //   path: 'addCert',
          //   name: 'addCert',
          //   component: () => import('@/views/lawyerCenter/lawyerCert/addCert/index'),
          //   meta: { title: '添加认证', icon: 'table' }
          // },
          {
            path: 'displayCert',
            name: 'displayCert',
            component: () => import('@/views/lawyerCenter/lawyerCert/displayCert/index'),
            meta: { title: '我的认证', icon: 'tree' }
          },
        ]
      },
      // 【服务商中心-我的通知】
      {
        path: '/lawyerNotice',
        name: 'lawyerNotice',
        component: () => import('@/views/lawyerCenter/lawyerNotice/index'),
        meta: { title: '我的通知', icon: 'el-icon-s-help', roles: ['serviceProvider'] },
        // meta: { title: '我的通知', icon: 'el-icon-s-help', roles: ['admin'] },
        children: [
          {
            path: 'displayList',
            name: 'displayList',
            component: () => import('@/views/lawyerCenter/lawyerNotice/displayList/index'),
            meta: { title: '我的通知', icon: 'table' }
          },
        ]
      },
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]


const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
